﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace CheckMemcached
{
    public class MailToAddressSection : ConfigurationSection
    {
        [ConfigurationProperty("MailToAddressCollection")]
        public MailToAddressCollection MailToAddressCollection
        {
            get { return this["MailToAddressCollection"] as MailToAddressCollection; }
            set { this["MailToAddressCollection"] = value; }
        }
    }
    public class MailToAddressCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new MailAddress();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            MailAddress ma = element as MailAddress;
            return ma.Address;
        }
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMap;
            }
        }
        protected override string ElementName
        {
            get
            {
                return "MailAddress";
            }
        }
    }
    public class MailAddress : ConfigurationElement
    {
        /// <summary>
        /// 邮件地址
        /// </summary>
        [ConfigurationProperty("Address", IsRequired = true, IsKey = true)]
        public string Address
        {
            get { return this["Address"] as string; }
            set { this["Address"] = value; }
        }
    }
}
